<?php
$star = '<span style="color:red">*</span>';
$errormsg = (isset($_GET['error']) && $_GET['error'] != '') ? $_GET['error'] : '';
$name = $action = $desc = "";
$sql = "SELECT * FROM tblpages WHERE id = $id";
$result = mysql_query($sql);
if(dbNumRows($result)){
	$row = mysql_fetch_assoc($result);
	
	$id = $row['id'];
	$name = $row['name'];
	$action = $row['name'];
	$desc = stripslashes($row['description']);
}
?>
<div class="breadcrumb">
        <a href="<?php echo base_url_admin;?>"><?php echo $lang['HOME'];?></a>
        :: <a href="<?php echo base_url_admin;?>/pages/index.php?view=list"><?php echo $lang['LIST_PAGE'];?></a>
         :: <a href="#"><?php echo isset($_GET['id'])?$lang['EDIT']:$lang['INSERT'];?></a>
      </div>
      <div class="box">
      	<?php 
		if(!empty($_GET['error'])&& $_GET['error']=="required"){
			?>
			<div class="warning"><?php echo $lang["MESSAGE_REQUIRED"];?></div>
			<?php 
		}
		if(!empty($_GET['error']) && $_GET['error']=="nameexist"){
			?>
			<div class="warning"><?php echo $lang["MESSAGE_NAMEEXIST"];?></div>
			<?php 
		}
	?>
<div class="heading">
	<h1><img src="../templates/image/order.png" alt="" />
		<?php 
			echo $lang["PAGE"];
		?>
		&nbsp;&nbsp;&nbsp;<span class="required">(*) all asterisks must be required!</span>
	</h1>
	<form action="<?php echo base_url_admin;?>/pages/process.php?action=add" method="post" name="frmPage" id="formPage">
	<div class="buttons">
	<input type="submit" name="btnsave" class="button" value="<?php echo $lang['PUBLISH'];?>"/>
		<a href="<?php echo base_url_admin;?>/pages/index.php?view=list" class="button"><?php echo $lang['BACK'];?></a></div>
</div>
<div class="content">
<table align="center" cellpadding="5" cellspacing="5" width="99%"> 
  <tr> 
   <td align="left" width="120"><?php echo $lang['PAGE_NAME']; ?> <font color="#FF0000">*</font></td>
   <td align="left" width="10">:</td>
   <td align="left"><input size="100" maxlength="50" name="txtpgname" type="text" value="<?php echo @$name?>" class="required"  required/></td>
  </tr>
  <tr> 
   <td align="left" valign="top"><?php echo $lang['DISCRIPTION']; ?></td>
   <td valign="top" align="left">:</td>
   <td align="left">
	<textarea id="txtdesc" name="texteditor" rows="20" cols="80" style="width: 100%">
		<?php
			if (isset($_GET['id'])) {
				echo $desc;
			} else {
				echo isset($_SESSION['desc']) ? $_SESSION['desc'] : '';
			}
		?>
	</textarea>
    <input type="hidden" name="hidid" value="<?php echo $id;?>" />
   </td>
  </tr>
 </table>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo base_url; ?>admin/templates/javascript/ckeditor/ckeditor.js"></script>
<script>
	$(document).ready(function() {
        CKEDITOR.replace('txtdesc', {
            filebrowserBrowseUrl: 'imageUpload.php',
            filebrowserImageBrowseUrl: 'imageUpload.php',
            filebrowserFlashBrowseUrl: 'imageUpload.php',
            filebrowserUploadUrl: 'imageUpload.php',
            filebrowserImageUploadUrl: 'imageUpload.php',
            filebrowserFlashUploadUrl: 'imageUpload.php',
            
        });
    });
    $('#tabs a').tabs();
</script>
